import {
  createRouter,
  createWebHashHistory,
  createWebHistory,
  RouteRecordRaw,
} from "vue-router";
import HomeView from "../views/HomeView.vue";
import HomePage from "@/pages/HomePage.vue";
import userLoginPage from "@/pages/user/userLoginPage.vue";
import { userRegister } from "@/api/user";
import userRegisterPage from "@/pages/user/userRegisterPage.vue";
import userManagerPage from "@/pages/router/userManagerPage.vue";
import component from "*.vue";
import loginBasicPage from "@/pages/basicLogin/loginBasicPage.vue";
import Dashboard from "@/pages/dashboard/DashBoardPage.vue";
import AdminDashboard from "@/pages/dashboard/AdminDashboardPage.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "userBasic",
    component: loginBasicPage,
  },
  {
    path: "/user/dashboard",
    name: "dashboard",
    component: Dashboard,
  },
  {
    path: "/user/adminDashboard",
    name: "adminDashboard",
    component: AdminDashboard,
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
  {
    path: "/user/login",
    name: "userLogin",
    component: userLoginPage,
  },
  {
    path: "/user/register",
    name: "userRegister",
    component: userRegisterPage,
  },
  {
    path: "/user/manager",
    name: "userManager",
    component: userManagerPage,
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  console.log("当前路由：", to.path);
  console.log("组件加载状态：", to.matched);
  next();
});

export default router;
